 package watercups.operators;

import watercups.states.WaterCupState;
import templates.Operator;

public class Empty2to1 implements Operator<WaterCupState>{
	public int getOperatorNumber(){
		return 6;
	}

	public boolean available(WaterCupState s){
		if(s.getCapacity1()<3 && s.getCapacity2()>0)
			return true;
		else
			return false;
	}

	public WaterCupState execute(WaterCupState s){
		int needToTransfer=3-s.getCapacity1();
		int transfered;
		if(needToTransfer<s.getCapacity2())
			transfered=needToTransfer;
		else
			transfered=s.getCapacity2();

		return new WaterCupState(s.getCapacity1()+transfered,s.getCapacity2()-transfered);
	}

	public String toString(){
		return "Emptying second cup into first cup";
	}
}